package com.song.sample.config.pagination;

import java.util.List;

/**
 * @desc: 自定义分页对象，分页结果封装自spring.data中的分页
 * @author: WUSONG
 * @date: 2018/6/25 0025 下午 2:51
 */
public class Page<T> {

    private int pageNum;

    private int pageSize;

    private int totalCount;

    private int totalPages;

    private List<T> list;

    public Page(int pageNum, int pageSize, int totalCount, int totalPages, List<T> list) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.totalPages = totalPages;
        this.list = list;
    }

    public Page(org.springframework.data.domain.Page page) {
        this.pageNum = page.getNumber()+1;
        this.pageSize = page.getSize();
        this.totalCount = page.getNumberOfElements();
        this.totalPages = page.getTotalPages();
        this.list = page.getContent();
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

}
